#include <bits/stdc++.h>
using namespace std;

template<typename T>
void benchmark(const string &name, const T &func) {
  auto start = chrono::high_resolution_clock::now();
  func();
  auto end = chrono::high_resolution_clock::now();
  auto duration = chrono::duration_cast<chrono::milliseconds>(end - start);
  cout << name << " execution time: " << duration.count() << "ms\n";
}

inline int pow(int x) {
  return x * x;
}
int pow2(int x) {
  return x * x;
}
mt19937 rnd(0);
int main() {
  int n = 300000000;
  vector<int> arr(n);
  for (auto &x : arr) x = rnd();
  
  benchmark("inline", [&]() {
    int sum = 0;
    for (int i = 0; i < n; i ++) {
      sum += pow(arr[i]);
    }
    cout << sum << endl;
  });

  benchmark("normal func", [&]() {
    int sum = 0;
    for (int i = 0; i < n; i ++) {
      sum += pow2(arr[i]);
    }
    cout << sum << endl;
  });

  auto pow3 = [](int i) {
    return i * i;
  };
  benchmark("lambda", [&]() {
    int sum = 0;
    for (int i = 0; i < n; i ++) {
      sum += pow3(arr[i]);
    }
    cout << sum << endl;
  });
}